package com.sc.nft.enums;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.compress.utils.Lists;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@AllArgsConstructor
@Getter
public enum EcologyPointsEnum {

    HATCH(1,"熔炼",Boolean.FALSE),
    CAST(2,"铸造",Boolean.FALSE),
    INCOME(3,"收益",Boolean.TRUE),
    CYCLE_INCOME(4,"周期收益",Boolean.TRUE),
    RECOMMENDED_INCOME(5,"分享收益",Boolean.TRUE),
    NODE_CULTIVATION_AWARD_365(6,"生态节点培育奖（365天）",Boolean.TRUE),
    NODE_CULTIVATION_AWARD_7(7,"生态节点培育奖（7天）",Boolean.TRUE),
    NODE_CONTRIBUTION_AWARD_365(8,"生态节点贡献奖（365天）",Boolean.TRUE),
    NODE_CONTRIBUTION_AWARD_7(9,"生态节点贡献奖（7天）",Boolean.TRUE),
    ECOLOGICAL_NODE_POSITION_AWARD(10,"生态节点持仓奖",Boolean.TRUE),
    ECOLOGICAL_CULTIVATION_AWARD_365(11,"生态培育奖（365天）",Boolean.TRUE),
    ECOLOGICAL_CULTIVATION_AWARD_7(12,"生态培育奖（7天）",Boolean.TRUE),
    CONTRIBUTION_AWARD_365(13,"生态贡献奖（365天）",Boolean.TRUE),
    CONTRIBUTION_AWARD_7(14,"生态贡献奖（7天）",Boolean.TRUE),
    COMMUNITY_ECOLOGICAL_CONTRIBUTION_AWARD_365(15,"社区生态贡献奖（365天）",Boolean.TRUE),
    COMMUNITY_ECOLOGICAL_CONTRIBUTION_AWARD_7(16,"社区生态贡献奖（7天）",Boolean.TRUE),
    city_CULTIVATION_AWARD_365(17,"城市生态培育奖（365天）",Boolean.TRUE),
    city_CULTIVATION_AWARD_7(18,"城市生态培育奖（7天）",Boolean.TRUE),
    city_CONTRIBUTION_AWARD_365(19,"城市生态贡献奖（365天）",Boolean.TRUE),
    city_CONTRIBUTION_AWARD_7(20,"城市生态贡献奖（7天）",Boolean.TRUE),

    DAO_CULTIVATION_AWARD(21,"DAO培育奖",Boolean.TRUE),
    DAO_CONTRIBUTION_AWARD(22,"DAO贡献奖",Boolean.TRUE),
    DAO_POSITION_BONUS_AWARD(23,"DAO持仓奖",Boolean.TRUE),
    REFORGE(24,"重铸",Boolean.FALSE),

    GIFT_PROPS(96,"转赠道具卡",Boolean.FALSE),
    COMPANY_ACCOUNT_IN(97,"企业账号转入",Boolean.TRUE),
    SYSTEM_ADD(99,"系统",Boolean.TRUE),
    SYSTEM_SUB(98,"系统",Boolean.FALSE),

    ;
    @EnumValue
    private int code;
    private String description;
    private Boolean isAdd;

    public static ArrayList<Map> getDescriptionAndName() {
        ArrayList<Map> enumList = Lists.newArrayList();
        EcologyPointsEnum[] values = values();
        for (EcologyPointsEnum v : values) {
            HashMap map = new HashMap<>();
            map.put("name",v.name());
            map.put("value",v.getDescription());
            if(v == SYSTEM_ADD){
                map.put("value", StrUtil.format("{}({})",v.getDescription(),"+"));
            }

            if(v == SYSTEM_SUB){
                map.put("value", StrUtil.format("{}({})",v.getDescription(),"-"));
            }

            enumList.add(map);
        }
        return enumList;
    }


    public static EcologyPointsEnum getByName(String name) {
        for (EcologyPointsEnum value : values()) {
            if(value.name().equals(name)){
                return value;
            }
        }
        return null;
    }


    public static void main(String[] args) {
//        ArrayList<Map> descriptionAndName = getDescriptionAndName();
//        System.out.println(descriptionAndName);

        EcologyPointsEnum[] values = values();
        String name = EcologyPointsEnum.NODE_CULTIVATION_AWARD_7.name();
        System.out.println(name);
    }
}
